<?php

error_reporting(E_ALL);
$relPath="../../pinc/";
include_once($relPath.'dpinit.php');
include_once($relPath.'dp_main.inc');

// Note: pagename is either provided if known,
// or the user wants the "next available" page.

$User->IsLoggedIn()
    or RedirectToLogin();


$projectid      = ArgProjectId();
$pagename       = ArgPageName();

if (! $projectid)
    die("parameter 'projectid' is invalid");

$project        = new DpProject($projectid);
$project->MayBeProofedByActiveUser()
    or die("Security violation.");

if($pagename != "") {
    $page           = new DpPage($projectid, $pagename);
    $page->MayBeSelectedByActiveUser()
        or die("Page unavailable to you.");
}

$urlproof       = url_for_proof_frame($projectid, $pagename);
// $urlproof       = "$proof_url/proof_frame.php"
                    // ."?projectid={$projectid}"
                    // . ($pagename ? "&pagename={$pagename}" : "");

$urlctls        = "$proof_url/ctrlframe.php";

$title          = "{$site_abbreviation}: "
                    ."[{$project->RoundId()}] "
                    ."{$project->Title()}";

echo 
"<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<script>
    var AJAX_URL = '{$ajax_url}';
    var SITE_URL = '{$site_url}';
</script>\n";

echo link_to_js("dp_edit.js");

echo "
<title>$title</title>
</head>

<frameset rows='*,78' onload='eBodyLoad()' onresize='top.eResize()'>
<frame id='proofframe' name='proofframe' src='{$urlproof}'>

<frame id='ctlsframe' name='ctlsframe' 
       noresize='noresize' src='{$urlctls}'>
</frameset>
<noframes>Your browser does not display frames!</noframes>
</html>";

?>
